package com.hotent.project.controller;


import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import com.hotent.base.model.CommonResult;
import com.hotent.base.util.StringUtil;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.RestController;
import com.hotent.base.controller.BaseController;
import com.hotent.project.model.WBdkj;
import com.hotent.project.manager.WBdkjManager;

/**
 * 表单控件 前端控制器
 *
 * @company 开发
 * @author 超级管理员
 * @since 2024-03-12
 */
@RestController
@RequestMapping("/wBdkj/v1/")
public class WBdkjController extends BaseController<WBdkjManager, WBdkj> {

	/**
	 * 根据id获取表单控件数据详情
	 * @param id
	 * @return
	 * @throws Exception 
	 * ModelAndView
	 */
	@GetMapping(value="/getDetail")
	@ApiOperation(value="根据id获取表单控件数据详情",httpMethod = "GET",notes = "根据id获取表单控件数据详情")
	public CommonResult<WBdkj> getDetail(@ApiParam(name="id",value="业务对象主键", required = true)@RequestParam(required=true) String id) throws Exception{
		return CommonResult.<WBdkj>ok().value(baseService.getDetail(id));
	}
    /**
	 * 新增,更新表单控件
	 * @param wBdkj
	 * @throws Exception 
	 * @return
	 * @exception 
	 */
	@PostMapping(value="/save")
	@ApiOperation(value = "新增,更新表单控件数据", httpMethod = "POST", notes = "新增,更新表单控件数据")
	public CommonResult<String> save(@ApiParam(name="WBdkj",value="表单控件对象", required = true)@RequestBody WBdkj wBdkj) throws Exception{
		String msg = StringUtil.isEmpty(wBdkj.getId()) ? "添加表单控件成功" : "更新表单控件成功";
		baseService.createOrUpdate(wBdkj);
		return CommonResult.<String>ok().message(msg);
	}
}
